package com.example.clxy.controller;

import com.example.clxy.interceptor.AppToken;
import com.example.clxy.result.WebRestResult;
import com.example.clxy.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;


/**
 * @author weichong
 * date 2020-08-07
 * @Description:
 */
@AppToken
@RestController
@RequestMapping("upload")
public class FileController {

    @Autowired
    private FileService fileService;

    /** 上传预习报告 **/
    @PostMapping("uploadStudentYxreport")
    public WebRestResult uploadStudentYxreport(@RequestParam("file")MultipartFile file,String scheduleid,String studentid){
        return fileService.uploadStudentYxreport(file,scheduleid,studentid);
    }

    /** 上传上传实验卡 **/
    @PostMapping("uploadStudentSycard")
    public WebRestResult uploadStudentSycard(@RequestParam("file")MultipartFile file,String scheduleid,String studentid){
        return fileService.uploadStudentSycard(file,scheduleid,studentid);
    }

    /** 上传实验报告 **/
    @PostMapping("uploadStudentSyreport")
    public WebRestResult uploadStudentSyreport(@RequestParam("file")MultipartFile file,String scheduleid,String studentid){
        return fileService.uploadStudentSyreport(file,scheduleid,studentid);
    }

    /** 上传老师头像 **/
    @PostMapping("uploadTeacherAvatar")
    public WebRestResult uploadTeacherAvatar(@RequestParam("file")MultipartFile file,String teacherid){
        return fileService.uploadTeacherAvatar(file,teacherid);
    }



    /** 下载平台问题模板 **/
    @RequestMapping("downloadPlatformQuestion")
    public void downloadPlatformQuestion(HttpServletResponse response){
        fileService.downloadPlatformQuestion(response);
    }

    /** 下载子实验问题模板 **/
    @RequestMapping("downloadExperimentQuestion")
    public void downloadExperimentQuestion(HttpServletResponse response){
        fileService.downloadExperimentQuestion(response);
    }

    /** 下载成绩导入模板 **/
    @RequestMapping("downloadScore")
    public void downloadScore(HttpServletResponse response,String scheduleid) {
        fileService.downloadScore(response,scheduleid);
    }

    /** 下载老师信息导入模板 **/
    @RequestMapping("downloadTeacher")
    public void downloadTeacher(HttpServletResponse response) {
        fileService.downloadTeacher(response);
    }

    /** 下载理论课程信息导入模板 **/
    @RequestMapping("downloadllCourse")
    public void downloadllCourse(HttpServletResponse response) {
        fileService.downloadllCourse(response);
    }

    /** 下载实验课程或平台与子实验关系导入模板 **/
    @RequestMapping("downloadgxExperiment")
    public void downloadgxExperiment(HttpServletResponse response) {
        fileService.downloadgxExperiment(response);
    }

    /** 下载实验课程信息导入模板 **/
    @RequestMapping("downloadsyCourse")
    public void downloadsyCourse(HttpServletResponse response) {
        fileService.downloadsyCourse(response);
    }

    /** 下载学生信息导入模板 **/
    @RequestMapping("downloadStudent")
    public void downloadStudent(HttpServletResponse response) {
        fileService.downloadStudent(response);
    }

    /** 下载子实验信息导入模板 **/
    @RequestMapping("downloadExperiment")
    public void downloadExperiment(HttpServletResponse response) {
        fileService.downloadExperiment(response);
    }



    /** 导入子实验信息 **/
    @RequestMapping("importExperiment")
    public WebRestResult importExperiment(@RequestParam("file")MultipartFile file){
        return fileService.importExperiment(file);
    }

    /** 导入学生信息 **/
    @RequestMapping("importStudent")
    public WebRestResult importStudent(@RequestParam("file")MultipartFile file){
        return fileService.importStudent(file);
    }

    /** 导入老师信息 **/
    @RequestMapping("importTeacher")
    public WebRestResult importTeacher(@RequestParam("file")MultipartFile file){
        return fileService.importTeacher(file);
    }

    /** 导入实验课程信息 **/
    @RequestMapping("importSycourse")
    public WebRestResult importSycourse(@RequestParam("file")MultipartFile file){
        return fileService.importSycourse(file);
    }

    /** 导入理论课程信息 **/
    @RequestMapping("importCourse")
    public WebRestResult importCourse(@RequestParam("file")MultipartFile file){
        return fileService.importCourse(file);
    }

    /** 导入平台问题信息 **/
    @RequestMapping("importPlatformQuestion")
    public WebRestResult importPlatformQuestion(@RequestParam("file")MultipartFile file){
        return fileService.importPlatformQuestion(file);
    }

    /** 导入子实验问题信息 **/
    @RequestMapping("importExperimentQuestion")
    public WebRestResult importExperimentQuestion(@RequestParam("file")MultipartFile file){
        return fileService.importExperimentQuestion(file);
    }

    /** 导入学生分数信息 **/
    @RequestMapping("importScore")
    public WebRestResult importScore(@RequestParam("file")MultipartFile file,String scheduleid){
        return fileService.importScore(file,scheduleid);
    }




    /** 导出学生信息 **/
    @RequestMapping("exportStudent")
    public void exportStudent(HttpServletResponse response, String grade, String classid){
        fileService.exportStudent(response,grade,classid);
    }





}
